package com.mmlc.meimei.lichengkongjian.mine;


import android.view.View;
import android.widget.TextView;

import com.androidnetframe.httputil.BaseRequestFilterLayer;
import com.androidnetframe.responsejavabean.RequestError;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.mmlc.inter.InterActivity;
import com.mmlc.meimei.lichengkongjian.App;
import com.mmlc.meimei.lichengkongjian.R;
import com.mmlc.meimei.lichengkongjian.customview.PayMethodLinearLayout;
import com.mmlc.network.filter.ShopOrderPayMethodRequestFilter;
import com.mmlc.widget.TitleBarView;

import butterknife.ButterKnife;
import butterknife.InjectView;

public class ShopOrder extends InterActivity {


    @InjectView(R.id.tb_titleBar)
    TitleBarView tbTitleBar;
    @InjectView(R.id.pull_refresh_list)
    PullToRefreshListView pullRefreshList;
    @InjectView(R.id.tv_shopName)
    TextView tvShopName;
    @InjectView(R.id.payMethod)
    PayMethodLinearLayout payMethod;

    @Override
    protected int initContentView() {
        return R.layout.activity_shoporder;
    }

    @Override
    protected void initView() {
        // TODO: add setContentView(...) invocation
        ButterKnife.inject(this);
        processData();
    }


    private void processData() {
        //处理TitleBar
        tbTitleBar.ll_left.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        tbTitleBar.setCenterName("店铺下单");

        tvShopName.setText(App.user.getShopName());

        final ShopOrderPayMethodRequestFilter filter = new ShopOrderPayMethodRequestFilter(this);
        filter.requestBean.platform="unline";
        filter.sendRequest(new BaseRequestFilterLayer.AccessResultFromFilter<String>() {

            @Override
            public void onSuccess(String result) {
                if(filter.orderBean == null){
                    return;
                }
                for(int i=0;i<filter.orderBean.size();i++){
                    payMethod.addItem(filter.orderBean.get(i).payName);
                }

            }

            @Override
            public void onFailed(View errorLayout, RequestError serverError, int failedType) {

            }
        });
    }

}
